home *** CD-ROM | disk | FTP | other *** search
- /*
- **
- ** $VER: RotateAnim.pprx 1.15 (16.08.2000)
- **
- ** (C)2000 Damir Arh, All Rights Reserved.
- **
- ** E-mail: damir.arh@telesat.si
- ** WWW: http://damir.gajba.net
- **
- ** FUNCTION:
- ** Creates rotation and scaling animation of the source image.
- **
- ** USAGE:
- ** It can be run directly from Shell or from within PPaint's ARexx window.
- ** There are no command line arguments, all parameters (source and
- ** destination filename, type and attributes of the animation) are specified
- ** in a GUI inside PPaint.
- **
- **
- ** $Id: RotateAnim.pprx,v 1.15 2000/08/16 13:14:11 damir Rel $
- **
- ** $Log: RotateAnim.pprx,v $
- ** Revision 1.15 2000/08/16 13:14:11 damir
- ** - Spanish translation added (thanks to Javier De Las Rivas <javierdlr@jazzfree.com>)
- **
- ** Revision 1.14 2000/08/03 12:39:41 damir
- ** - French translation added (thanks to Pascal Chiozzi <Micks99@gmx.net>)
- **
- ** Revision 1.13 2000/08/02 17:46:17 damir
- ** - Italian translation added (thanks to Matteo Cavalleri <shiva.brahma@inwind.it>)
- **
- ** Revision 1.12 2000/07/29 20:01:46 damir
- ** - implemented scaling
- ** - cleaned up and additionally commented the code
- **
- ** Revision 1.11 2000/07/28 15:34:58 damir
- ** - fixed a bug in animation rotation with a custom axis
- ** - removed support for manipulating animations
- **
- ** Revision 1.10 2000/07/27 14:01:05 damir
- ** - implemented a function for the positioning of the rotation axis
- **
- ** Revision 1.9 2000/07/24 22:24:53 damir
- ** - fixed a bug which could cause the animation to be cut off in some cases
- ** - removed a forgotten debug printout
- **
- ** Revision 1.8 2000/07/21 19:45:53 damir
- ** - the script can now also be preformed on animations and anim-brushes
- ** - parts of the script have been cleaned up by the use of specific functions
- **
- ** Revision 1.7 2000/07/21 10:57:04 damir
- ** - the animation can now be also saved as an anim-brush
- **
- ** Revision 1.6 2000/07/20 15:00:14 damir
- ** - the image doesn't get cut off any more when rotated round the z-axis
- **
- ** Revision 1.5 2000/07/20 13:43:48 damir
- ** - implemented localization support
- ** - added the Slovenian translation as a sample
- **
- ** Revision 1.4 2000/07/20 13:21:23 damir
- ** - implemented a selection of the rotation orientation
- ** - added keyboard shortcuts to the requesters
- **
- ** Revision 1.3 2000/07/11 12:42:06 damir
- ** - implemented rotation round z-axis
- ** - increased the number of frames upper limit
- **
- ** Revision 1.2 2000/07/08 16:02:41 damir
- ** - implemented the rotation round the x-axis
- **
- ** Revision 1.1 2000/07/07 16:04:54 damir
- ** Initial revision
- **
- **
- */
-
- msg_title = 'RotateAnim v1.15'
-
-
- /* run PPaint if necessary, complain in case of problems */
-
- if arg(1,exists) then
- parse arg PPport
- else
- PPport = 'PPAINT'
-
- if ~show(ports,PPport) then do
- if exists('PPaint:PPaint') then do
- address command 'Run >NIL: PPaint:PPaint'
- do 30 while ~show(ports,PPport)
- address command 'Wait >NIL: 1 SEC'
- end
- end
- else do
- say "Personal Paint could not be loaded."
- exit 10
- end
- end
-
- if ~show(ports,PPport) then do
- say 'Personal Paint Rexx port could not be opened'
- exit 10
- end
-
- /* starting setup */
-
- address value PPport
- options results
- options failat 10000
-
-
- /* strings and language selection */
-
- GET 'LANG'
-
- if RESULT = 15 then do /* Slovensko by Damir Arh <damir.arh@telesat.si> */
- msg_source_type = 'Izberite vrsto izvorne datoteke'
- msg_source_file = 'Izberite izvorno datoteko...'
- msg_number_frames = 'Vnesite tevilo sliic'
- msg_multiplier = 'Vnesite vekratnik tevila sliic'
- msg_select_anim = 'Izberite vrsto ustvarjene animacije'
- msg_rotate = '_Rotacija'
- msg_scale = '_Sprem. velikosti'
- msg_select_axis = 'Izberite os rotacije'
- msg_x = 'Os _X'
- msg_y = 'Os _Y'
- msg_z = 'Os _Z'
- msg_select_orient = 'Izberite orientacijo rotacije'
- msg_pos = '_Pozitivna'
- msg_neg = '_Negativna'
- msg_save_method = 'Kako elite animacijo shraniti?'
- msg_image = '_Slika'
- msg_anim = '_Animacija'
- msg_brush = 'Anim. o_pi'
- msg_axis_pos = 'Koordinate osi'
- msg_dest_pos = 'Koordinate ponora'
- msg_x_coord = 'X'
- msg_y_coord = 'Y'
- end
- else if result = 2 then do /* Italiano by Matteo Cavalleri <shiva.brahma@inwind.it> */
- msg_source_type = 'Scegli il tipo del file sorgente'
- msg_source_file = 'Scegli il file sorgente...'
- msg_number_frames = 'Immetti il numero dei frames'
- msg_multiplier = 'Immetti il moltiplicatore dei frames'
- msg_select_anim = 'Scegli il tipo dell''animazione creata'
- msg_rotate = '_Rotazione'
- msg_scale = '_Scalatura'
- msg_select_axis = 'Seleziona l''asse per la rotazione'
- msg_x = 'Asse _X'
- msg_y = 'Asse _Y'
- msg_z = 'Asse _Z'
- msg_select_orient = 'Seleziona l''orientamento della rotazione'
- msg_pos = '_Positivo'
- msg_neg = '_Negativo'
- msg_save_method = 'Come vuoi salvare l''animazione?'
- msg_image = '_Immagine'
- msg_anim = '_Animazione'
- msg_brush = 'Anim-_brush'
- msg_axis_pos = 'Coordinate assi'
- msg_dest_pos = 'Coordinate destinazione'
- msg_x_coord = 'X'
- msg_y_coord = 'Y'
- end
- else if result = 3 then do /* Français by Pascal Chiozzi <Micks99@gmx.net> */
- msg_source_type = 'Sélectionner le type de fichier source'
- msg_source_file = 'Sélectionner le fichier source...'
- msg_number_frames = 'Entrer le nombres d''images'
- msg_multiplier = 'Entrer le multiplicateur'
- msg_select_anim = 'Sélectionner le type d''animation à créer'
- msg_rotate = '_Rotation'
- msg_scale = 'Re_dimensionner'
- msg_select_axis = 'Sélectionner l''axe de rotation'
- msg_x = 'Axe-_X'
- msg_y = 'Axe-_Y'
- msg_z = 'Axe-_Z'
- msg_select_orient = 'Sélectionner l''orientation de la rotation'
- msg_pos = '_Positive'
- msg_neg = '_Negative'
- msg_save_method = 'Comment veux-tu sauver l''animation?'
- msg_image = '_Image'
- msg_anim = '_Animation'
- msg_brush = '_Brosse anim'
- msg_axis_pos = 'Coordonnées de l''axe'
- msg_dest_pos = 'Coordonnées de destination'
- msg_x_coord = 'X'
- msg_y_coord = 'Y'
- end
- else if result = 4 then do /* Español by Javier de las Rivas <javierdlr@jazzfree.com> */
- msg_source_type = 'Tipo de fichero fuente'
- msg_source_file = 'Elija el fichero fuente...'
- msg_number_frames = 'Nº de fotogramas:'
- msg_multiplier = 'Nº fotogramas ×'
- msg_select_anim = 'Tipo de animación a crear'
- msg_rotate = '_Rotar'
- msg_scale = 'Re_escalar'
- msg_select_axis = 'Elija el eje de rotación'
- msg_x = 'Eje-_X'
- msg_y = 'Eje-_Y'
- msg_z = 'Eje-_Z'
- msg_select_orient = 'Orientación de rotación'
- msg_pos = '_Positiva'
- msg_neg = '_Negativa'
- msg_save_method = 'Salvar fichero como'
- msg_image = '_Imagen'
- msg_anim = '_Animación'
- msg_brush = '_Brocha-Anim'
- msg_axis_pos = 'Eje de coordenadas'
- msg_dest_pos = 'Tamaño del destino'
- msg_x_coord = 'X:'
- msg_y_coord = 'Y:'
- end
- else do /* English by Damir Arh <damir.arh@telesat.si> */
- msg_source_type = 'Select the type of source file'
- msg_source_file = 'Select source file...'
- msg_number_frames = 'Enter number of frames'
- msg_multiplier = 'Enter frames multiplier'
- msg_select_anim = 'Select the type of the created animation'
- msg_rotate = '_Rotation'
- msg_scale = '_Scaling'
- msg_select_axis = 'Select the axis for the rotation'
- msg_x = '_X-axis'
- msg_y = '_Y-axis'
- msg_z = '_Z-axis'
- msg_select_orient = 'Select the orientation of the rotation'
- msg_pos = '_Positive'
- msg_neg = '_Negative'
- msg_save_method = 'How would you like to save the animation?'
- msg_image = '_Image'
- msg_anim = '_Animation'
- msg_brush = 'Anim-_brush'
- msg_axis_pos = 'Axis coordinates'
- msg_dest_pos = 'Destination coordinates'
- msg_x_coord = 'X'
- msg_y_coord = 'Y'
- end
-
-
- /* ask the user for parameters */
-
- REQUEST '"'msg_title'" ' ||, /* source file type */
- '"TEXT = ""'msg_source_type'"" ' ||,
- ' ACTION = ""'msg_image'"" ' ||,
- ' ACTION = ""'msg_brush'"" "'
-
- if rc = 0 then
- Type = RESULT
- else
- exit
-
- REQUESTFILE '"'msg_source_file'"' /* source filename */
-
- if rc = 0 then
- Source = RESULT
- else
- exit
-
- if Type = 1 then do /* number of frames */
- REQUEST '"'msg_title'" ' ||, /* image */
- '"INTSTR = ""'msg_number_frames'"", 1, 500, 50 '
-
- if rc = 0 then
- Frames = RESULT.1
- else
- exit
- end
- else do
- REQUEST '"'msg_title'" ' ||, /* animation */
- '"INTSTR = ""'msg_multiplier'"", 1, 10, 1 '
-
- if rc = 0 then
- Multiplier = RESULT.1
- else
- exit
- end
-
- REQUEST '"'msg_title'" ' ||, /* animation type */
- '"TEXT = ""'msg_select_anim'"" ' ||,
- ' ACTION = ""'msg_rotate'"" ' ||,
- ' ACTION = ""'msg_scale'"" "'
-
- if rc = 0 then
- Process = RESULT
- else
- exit
-
- if Process = 1 then do /* rotation */
-
- REQUEST '"'msg_title'" ' ||, /* axis */
- '"TEXT = ""'msg_select_axis'"" ' ||,
- ' ACTION = ""'msg_x'"" ' ||,
- ' ACTION = ""'msg_y'"" ' ||,
- ' ACTION = ""'msg_z'"" "'
-
- if rc = 0 then
- Axis = RESULT
- else
- exit
-
- if Axis = 3 then do
-
- REQUEST '"'msg_title'" ' ||, /* orientation */
- '"TEXT = ""'msg_select_orient'"" ' ||,
- ' ACTION = ""'msg_pos'"" ' ||,
- ' ACTION = ""'msg_neg'"" "'
-
- if rc = 0 then
- Orientation = RESULT
- else
- exit
-
- end
-
- end
-
- /* get source attributes */
-
- LOADBRUSH Source
- GETBRUSHATTRIBUTES HANDLEX
- hx = RESULT
- GETBRUSHATTRIBUTES HANDLEY
- hy = RESULT
- GETBRUSHATTRIBUTES WIDTH
- x = RESULT - 1
- GETBRUSHATTRIBUTES HEIGHT
- y = RESULT - 1
-
- /* axis coordinates */
-
- if Axis = 1 then do
- msg_y_coord1 = msg_y_coord || ' (1-' || y || ')'
- REQUEST '"'msg_axis_pos'" ' ||,
- '"INTSTR = ""'msg_y_coord1'"", 1, 'y', 'hy' "'
- if rc = 0 then
- AxisY = RESULT.1
- else
- exit
- GETBRUSHATTRIBUTES HANDLEX
- AxisX = RESULT
- end
- else if Axis = 2 then do
- msg_x_coord1 = msg_x_coord || ' (1-' || x || ')'
- REQUEST '"'msg_axis_pos'" ' ||,
- '"INTSTR = ""'msg_x_coord1'"", 1, ' || x || ', 'hx' "'
- if rc = 0 then
- AxisX = RESULT.1
- else
- exit
- GETBRUSHATTRIBUTES HANDLEY
- AxisY = RESULT
- end
- else if Axis = 3 then do
- msg_x_coord1 = msg_x_coord || ' (1-' || x || ')'
- msg_y_coord1 = msg_y_coord || ' (1-' || y || ')'
- REQUEST '"'msg_axis_pos'" ' ||,
- '"INTSTR = ""'msg_x_coord1'"", 1, ' || x || ', 'hx' ' ||,
- ' INTSTR = ""'msg_y_coord1'"", 1, 'y', 'hy' "'
- if rc = 0 then do
- AxisX = RESULT.1
- AxisY = RESULT.2
- end
- else
- exit
- end
- else do /* scaling */
- msg_x_coord1 = msg_x_coord || ' (1-' || x || ')'
- msg_y_coord1 = msg_y_coord || ' (1-' || y || ')'
- REQUEST '"'msg_dest_pos'" ' ||,
- '"INTSTR = ""'msg_x_coord1'"", 1, ' || x || ', 'hx' ' ||,
- ' INTSTR = ""'msg_y_coord1'"", 1, 'y', 'hy' "'
- if rc = 0 then do
- AxisX = RESULT.1
- AxisY = RESULT.2
- end
- else
- exit
- end
-
- REQUEST '"'msg_title'" ' ||, /* save filename */
- '"TEXT = ""'msg_save_method'"" ' ||,
- ' ACTION = ""'msg_anim'"" ' ||,
- ' ACTION = ""'msg_brush'"" "'
-
- if rc = 0 then
- Method = RESULT
- else
- exit
-
-
- /* setup the environment */
-
- LOCKGUI
- DELETEFRAMES ALL FORCE
- LOADIMAGE Source FORCE
- CLEARIMAGE FORCE
-
- /* calculate brush attributes */
-
- bx = max(AxisX,2*hx-AxisX)
- by = max(AxisY,2*hy-AxisY)
- BrushWidth = 2 * bx
- BrushHeight = 2 * by
-
- /* load the source image and modify it for the effect */
-
- SETCURRENTBRUSH 1
- if Type = 1 then do /* image */
- LOADBRUSH Source
- if Axis ~= 3 then do
- SETBRUSHHANDLE AxisX AxisY
- PUTBRUSH bx by
- DEFINEBRUSH 0 0 BrushWidth BrushHeight
- CLEARIMAGE FORCE
- end
- end
- else do /* animated brush */
- LOADANIMBRUSH Source
- GETANIMBRUSHSETTINGS 'FRAMES'
- BrFrames = RESULT
- ADDFRAMES BrFrames
- do i = 1 to BrFrames
- SETFRAMEPOSITION i
- SETBRUSHATTRIBUTES FRAMEPOSITION i
- if Axis = 3 then do
- PUTBRUSH hx hy
- end
- else do
- SETBRUSHHANDLE AxisX AxisY
- PUTBRUSH bx by
- end
- end
- SETFRAMEPOSITION 1
- if Axis = 3 then do
- GETBRUSHATTRIBUTES WIDTH
- BrushWidth = RESULT
- GETBRUSHATTRIBUTES HEIGHT
- BrushHeight = RESULT
- end
- GETFRAMES
- BrFrames = RESULT
- COPYENVIRONMENT ANIMATION FORCE
- SWITCHENVIRONMENT
- DELETEFRAMES ALL FORCE
- CLEARIMAGE FORCE
- Frames = BrFrames * Multiplier
- end
-
- ADDFRAMES Frames
-
- /* in case of z-axis rotation or scaling set correct position for the effect */
-
- if Process = 2 then do
- bx = AxisX
- by = AxisY
- end
- else if Axis = 3 then do
- SETBRUSHHANDLE AxisX AxisY
- GETDISTANCE 0 0 max(AxisX,2*hx-AxisX) max(AxisY,2*hy-AxisY)
- bx = RESULT
- by = RESULT
- end
- SET 'FORCE "IMAGEW='2*bx'" "IMAGEH='2*by'"'
-
- /* set final animation size */
-
- if Process = 1 then do
- FBrushWidth = 2 * bx
- FBrushHeight = 2 * by
- end
- else do
- FBrushWidth = x
- FBrushHeight = y
- end
-
-
- /* draw the first frame - unchanged image */
-
- SETFRAMEPOSITION 1
- if Type ~= 1 then do
- SWITCHENVIRONMENT
- SETFRAMEPOSITION 1
- DEFINEBRUSH 0 0 BrushWidth BrushHeight
- SWITCHENVIRONMENT
- end
- PUTBRUSH bx by
-
-
- /* draw the rest of the frames */
-
- SETCURRENTBRUSH 2
- k = 4 / Frames
- if Axis = 1 then
- BrushSize = FBrushHeight
- else do
- if Axis = 2 then
- BrushSize = FBrushWidth
- else
- BrushSize = 90000
- end
-
- do i = 2 to Frames
-
- /* obtain the default image */
-
- FREEBRUSH FORCE
- COPYBRUSH 1
- if Type ~= 1 then do
- SWITCHENVIRONMENT
- SETFRAMEPOSITION ( (i - 1) // BrFrames ) + 1
- DEFINEBRUSH 0 0 BrushWidth BrushHeight
- SWITCHENVIRONMENT
- end
- SETFRAMEPOSITION i
- size = (i - 1) * k
-
- if Process = 2 then do /* scaling */
- NBrushWidth = max(1,trunc(abs(size / 2 - 1) * BrushWidth,0))
- NBrushHeight = max(1,trunc(abs(size / 2 - 1) * BrushHeight,0))
- end
- else if Axis = 3 then /* z-axis rotation */
- NewSize = trunc(BrushSize * size,0)
- else do
-
- /* 0 - 90 degrees */
-
- if size < 1 then do
- size = 1 - size
- NewSize = trunc(BrushSize * size,0)
- size = -1
- end
-
- /* 90 or 270 degrees */
-
- if size = 1 | size = 3 then do
- NewSize = 1
- size = -1
- end
-
- /* 270 - 360 degrees */
-
- if size > 3 then do
- size = size - 3
- NewSize = trunc(BrushSize * size,0)
- size = -1
- end
-
- /* 180 - 270 degrees */
-
- if size > 2 then do
- size = 3 - size
- NewSize = trunc(BrushSize * size,0)
- size = -2 /* indicates the need for flipping */
- end
-
- /* 90 - 180 degrees */
-
- if size > 1 then do
- size = size - 1
- NewSize = trunc(BrushSize * size,0)
- size = -2 /* indicates the need for flipping */
- end
-
- end
-
- /* perform the transformation */
-
- if Process = 1 then do /* rotation */
- if Axis = 1 then do
- if size = -2 then do
- FLIPBRUSH VERTICAL
- end
- SETBRUSHATTRIBUTES HEIGHT NewSize
- end
- else do
- if Axis = 2 then do
- if size = -2 then do
- FLIPBRUSH HORIZONTAL
- end
- SETBRUSHATTRIBUTES WIDTH NewSize
- end
- else
- if Orientation = 2 then
- ROTATEBRUSH NewSize
- else
- ROTATEBRUSH 360000-NewSize
- end
- end
- else do /* scaling */
- SETBRUSHATTRIBUTES WIDTH NBrushWidth HEIGHT NBrushHeight
- end
-
- PUTBRUSH bx by
-
- end
-
- /* save the animation at the end */
-
- UNLOCKGUI
-
- if Method = 2 then do
- DEFINEBRUSH 0 0 FBrushWidth FBrushHeight Frames
- SAVEANIMBRUSH
- end
- else
- SAVEANIMATION
-